/**
 * @file 工单操作-页面加载完毕之后 获取路由
 * @author sunlife <1298629573@qq.com>
 * @date 2020-11-11
 */
layui.define([], function (exports) {

    function _calculateHostForERP () {
        var currHost =  location.host;
        var host;
        if (/:/.test(currHost)) {
            host = 'http://dev-finance.xiujiadian.com:13013';
        } else if (/test-/.test(currHost)) {
            host = 'http://test-finance.xiujiadian.com';
        } else if (/test2-/.test(currHost)) {
            host = 'http://test2-finance.xiujiadian.com';
        } else if (/uat-/.test(currHost)) {
            host = 'http://uat-finance.xiujiadian.com';
        }else if (/pre-/.test(currHost)) {
			host = 'http://pre-finance.xiujiadian.com';
		}
		else {
            host = 'https://finance.xiujiadian.com';
        }
        return host;
    }

    function _calculateHostForOMS () {
        var currHost =  location.host;
        var host;
        if (/:/.test(currHost)) {
            host = 'http://dev-oms.xiujiadian.com:10213';
        } else if (/test-/.test(currHost)) {
            host = 'http://test-oms.xiujiadian.com';
        } else if (/test2-/.test(currHost)) {
            host = 'http://test2-oms.xiujiadian.com';
        } else if (/uat-/.test(currHost)) {
            host = 'http://uat-oms.xiujiadian.com';
        } else if (/pre-/.test(currHost)) {
			host = 'http://pre-oms.xiujiadian.com';
		} else {
            host = 'https://oms.xiujiadian.com';
        }
        return host;
    }

    function _calculateHostForTRACK () {
        var currHost =  location.host;
        var host;
        if (/:/.test(currHost)) {
            host = 'http://dev-track.xiujiadian.com:13513';
        } else if (/test-/.test(currHost)) {
            host = 'http://test-track.xiujiadian.com';
        } else if (/test2-/.test(currHost)) {
            host = 'http://test2-track.xiujiadian.com';
        } else if (/uat-/.test(currHost)) {
            host = 'http://uat-track.xiujiadian.com';
        } else if (/pre-/.test(currHost)) {
			host = 'http://pre-track.xiujiadian.com';
		} else {
            host = 'https://track.xiujiadian.com';
        }
        return host;
    }

    function _calculateHostForCOMMENT () {
        var currHost =  location.host;
        var host;
        if (/:/.test(currHost)) {
            host = 'http://dev-comment.xiujiadian.com:15713';
        } else if (/test-/.test(currHost)) {
            host = 'http://test-comment.xiujiadian.com';
        } else if (/test2-/.test(currHost)) {
            host = 'http://test2-comment.xiujiadian.com';
        } else if (/uat-/.test(currHost)) {
            host = 'http://uat-comment.xiujiadian.com';
        } else if (/pre-/.test(currHost)) {
            host = 'http://pre-comment.xiujiadian.com';
        } else {
            host = 'https://comment.xiujiadian.com';
        }
        return host;
    }

    function _routeToDetail(workId, orderId) {
        window.location.href = _calculateHostForOMS() + '/work/modify/detail.action?orderId='+ orderId +'&workId='+ workId +'&operateId=103&moduleId=510';
    }

    exports('oms_work_modify_route', {
        _calculateHostForERP: _calculateHostForERP,
        _calculateHostForOMS: _calculateHostForOMS,
        _calculateHostForTRACK: _calculateHostForTRACK,
        _calculateHostForCOMMENT: _calculateHostForCOMMENT,
        _routeToDetail: _routeToDetail
    });
});
